<?php
/**
 * Created by PhpStorm.
 * User: Andy
 * Date: 2019/1/30
 * Time: 10:13
 */

namespace App\swoole\controller;


use Common\controller\Controller;

class Test extends Controller
{
    public function index(){
        try{
            $serv = new Server('0.0.0.0', 9501, SWOOLE_BASE, SWOOLE_SOCK_TCP);
            $serv->set(array(
                'worker_num' => 4,
                'daemonize' => true,
                'backlog' => 128,
            ));
            $serv->on('Connect', function ($serv,$fd){
                echo '建立连接--';
                '$serv:='.var_dump($serv);
                '$fd:='.var_dump($fd);
            });

           // $serv->on('Receive', 'my_onReceive');
            //$serv->on('Close', 'my_onClose');
            $serv->start();

           /* $serv->manager_pid;  //管理进程的PID，通过向管理进程发送SIGUSR1信号可实现柔性重启
            $serv->master_pid;  //主进程的PID，通过向主进程发送SIGTERM信号可安全关闭服务器
            $serv->connections; //当前服务器的客户端连接，可使用foreach遍历所有连接
            var_dump($serv);*/

        }catch(\Exception $e){
            var_dump($e->getMessage());

        }

    }

}